//
//  RankingHeader.swift
//  SLQuickReader
//
//  Created by ALin on 2017/8/11.
//  Copyright © 2017年 ALin. All rights reserved.
//

import UIKit

class RankingHeader: BaseXibView {
    
    @IBOutlet weak var manBtn: UIButton!
    
    @IBOutlet weak var girlBtn: UIButton!
    
    var selectedBtn: UIButton!
    
    
    var clickBlock: (Int)->() = {_ in }
    
    
    private let g_color = UIColor.colorWithHexString(hex: "#e53325")
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
        manBtn.masksToBounds(manBtn.height * 0.5)
        girlBtn.masksToBounds(girlBtn.height * 0.5)
        girlBtn.setBorder(width: 1, color: g_color)
        manBtn.setBorder(width: 1, color: g_color)
        
        manBtn.setBackgroundColor(normal: UIColor.white, selected: g_color)
        girlBtn.setBackgroundColor(normal: UIColor.white, selected: g_color)
        
        // 默认选中
        selectedBtn = manBtn
        manBtn.isSelected = true
    }
    
    @IBAction func click(_ sender: UIButton) {
        clickBlock(sender == manBtn ? 0 : 1);
        
        selectedBtn.isSelected = false
        sender.isSelected = true
        selectedBtn = sender
    }
    

}
